package com.ruoyi.project.menzhen.controller;

import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.menzhen.domain.User;
import com.ruoyi.project.menzhen.service.UserService;
import com.ruoyi.project.system.domain.SysPost;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping(value="/menzhen/user",method=RequestMethod.GET)
public class MenzhenUserController extends BaseController {
    @Autowired
    private UserService userService;
    @PreAuthorize("@ss.hasPermi('system:user:query')")
    @GetMapping(value = "/{userId}")
    public AjaxResult getInfo(@PathVariable Long userId)
    {
        return AjaxResult.success(userService.selectUserById(userId));
    }
    @PreAuthorize("@ss.hasPermi('menzhen:user:list')")
    @GetMapping("/list")
    public TableDataInfo list(User user)
    {
        startPage();
        List<User> list = userService.selectUserList(user);
        return getDataTable(list);
    }
    @PreAuthorize("@ss.hasPermi('menzhen:user:add')")
    @Log(title = "患者管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add( @RequestBody User user)
    {

        return toAjax(userService.insertUser(user));
    }
    @PreAuthorize("@ss.hasPermi('menzhen:user:edit')")
    @Log(title = "岗位管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit( @RequestBody User user)
    {
        return toAjax(userService.updateUser(user));
    }

}
